home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-08 | 47.5 KB | 1,442 lines | [TEXT/R*ch] |
- C.S.M.P. Digest Sun, 04 Oct 92 Volume 1 : Issue 174
-
- Today's Topics:
-
- Looking for some sample appletalk ATP code...
- MacinTalk MPW C Interfaces
- screenBits, off-screen drawing and memory allocation
- ZREF error
- Getting my hands on the real CLUT
- FSpExchangeFiles Problem
- Accepting AppleEvents?
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- The digest is a collection of article threads from the internet newsgroup
- comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
- regularly and want an archive of the discussions. If you don't know what a
- newsgroup is, you probably don't have access to it. Ask your systems
- administrator(s) for details. (This means you can't post questions to the
- digest.)
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- cs.uoregon.edu). Article threads are not added to the digest until the last
- article added to the thread is at least one month old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
- [128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
- file /pub/mac/csmp-digest/README before downloading any files. The most
- recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
- directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
- archive has a mail server; send a message with the text '$MACarch help' (no
- quotes) to LISTSERV@ricevm1.rice.edu for more information.
-
- The digest is also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new issue as it is created. Sorry, back issues
- are not available through the mailing list.
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
-
- -------------------------------------------------------
-
- From: bratton@sparc3.cs.uiuc.edu (Alex Bratton)
- Subject: Looking for some sample appletalk ATP code...
- Organization: University of Illinois at Urbana-Champaign
- Date: Tue, 1 Sep 1992 03:36:35 GMT
-
- I've been doing some work with ATP, trying to get a socket opened and the
- name registered. It returns noErr, but when I examine the network from
- another computer, the new socket doesn't show up. It also produces an
- error (no matching name) when I try to unregister the name.
-
- If you have some sample code (ATP) that opens, registers, and dumps some
- data, I'd really appreciate seeing it. This has been bugging me for a while
- and I think I need to look at some working code to see what I'm missing.
-
- I'm sticking with ATP to insure system 6 & 7 compatability.
-
- Thanks,
- Alex Bratton
-
- +++++++++++++++++++++++++++
-
- From: cheshire@cs.stanford.edu (Stuart Cheshire)
- Date: 2 Sep 92 17:58:33 GMT
- Organization: Stanford University
-
- In article <1992Sep1.033635.28604@sunb10.cs.uiuc.edu> Alex Bratton,
- bratton@sparc3.cs.uiuc.edu writes:
- >If you have some sample code (ATP) that opens, registers, and dumps some
- >data, I'd really appreciate seeing it. This has been bugging me for a
- while
- >and I think I need to look at some working code to see what I'm missing.
-
- Here is some sample code which includes ATP calls. It is the code I use
- to obtain the list of AppleTalk zones to display in my game Bolo, and
- judging by the time it took to get all the wrinkles worked out, and make
- it run with both Phase 1 and Phase 2, it probably should be in some
- sample code library somewhere for other people's use.
-
- The ATP calls are in the Phase 1 part, which has to communicate directly
- with the bridge via ATP.
-
- The code gets the list of zones, sorts them into alphabetical order using
- heap sort, and then appends them in order to the list identified by the
- parameter "zonelist", which should be initialized before calling
- getzonelist.
-
- The code is written for Think C 5.
-
- #include <AppleTalk.h>
-
- #define local static
- #define export
- #define import extern
-
- typedef struct
- {
- BYTE sysLAPAddr;
- BYTE destnode;
- BYTE srcnode;
- BYTE ALAPproto;
- WORD length;
- union
- {
- struct
- {
- BYTE destsocket;
- BYTE srcsocket;
- BYTE DPPproto;
- BYTE userdata[15];
- } shortheader;
- struct
- {
- WORD checksum;
- WORD destnet;
- WORD srcnet;
- BYTE destnode;
- BYTE srcnode;
- BYTE destsocket;
- BYTE srcsocket;
- BYTE DPPproto;
- BYTE userdata[7];
- } longheader;
- } u;
- BYTE unused;
- BYTE sysABridge;
- WORD sysNetNum;
- WORD vSCCEnable;
- } MPPglobals;
-
- extern MPPglobals *ABusVars : 0x2D8;
-
- #define atpMaxData 578 // size of buffer for zone names
- #define kZIPSocket 6 // the Zone Information Protocol socket
- #define kATPTimeOutVal 3 // re-try ATP SendRequest every 3 seconds
- #define kATPRetryCount 5 // for five times
- #define kGZLCall 0x08000000 // GetZoneList indicator
- #define kGMZCall 0x07000000 // GetMyZone indicator
- #define kZoneCount 0x0000FFFF // mask to count zones in buffer
- #define kNoMoreZones 0xFF000000 // mask to see if more zones to come
-
- #define xCall 246
- #define zipGetLocalZones 5
- #define zipGetZoneList 6
- #define zipGetMyZone 7
-
- typedef struct
- {
- QElemPtr qLink;
- short qType;
- short ioTrap;
- Ptr ioCmdAddr;
- ProcPtr ioCompletion;
- OSErr ioResult;
- StringPtr ioNamePtr;
- short ioVRefNum;
- short ioRefNum;
- short csCode;
- short xppSubCode;
- unsigned char xppTimeOut;
- unsigned char xppRetry;
- short filler;
- Ptr zipBuffPtr;
- short zipNumZones;
- short zipLastFlag;
- short zipInfoField[35];
- } xCallParam;
-
- #define MAX_ZONES 1000
- typedef struct { unsigned char c[34]; } ZONE_NAME;
- ZONE_NAME *zone_array, **zone_heap;
- local int num_zones;
-
- local void addtoheap(int place, ZONE_NAME *new)
- {
- int parent = (place-1)>>1;
- zone_heap[place]=new;
- while (place>0 && IUCompString(zone_heap[parent]->c,
- zone_heap[place]->c)>0)
- {
- ZONE_NAME *temp = zone_heap[place ];
- zone_heap[place ] = zone_heap[parent];
- zone_heap[parent] = temp;
- place=parent;
- parent=(place-1)>>1;
- }
- }
-
- local ZONE_NAME *removefromheap(int last) // last is index of last item
- on heap
- {
- ZONE_NAME *top = zone_heap[0]; // extract top element
- int gap = 0; // top is now empty
- int left = 1;
- int right = 2;
- while(left<=last) // move gap to bottom
- {
- if(right>last || IUCompString(zone_heap[right]->c,
- zone_heap[left]->c)>0)
- { zone_heap[gap]=zone_heap[left ]; gap=left; }
- else{ zone_heap[gap]=zone_heap[right]; gap=right; }
- left = (gap<<1)+1;
- right = left + 1;
- }
- if(last != gap) addtoheap(gap, zone_heap[last]); // fill gap
- return(top); // and heap is now one element smaller
- }
-
- local void BuildZoneListPhase1(unsigned char *myzone)
- {
- ATPParamBlock pb;
- BDSElement dBDS;
- unsigned char datapacket[atpMaxData];
- short zIndex=1, zCount=0, i;
-
- dBDS.buffSize = atpMaxData;
- dBDS.buffPtr = (Ptr)datapacket;
-
- pb.ATPatpFlags = 0;
- pb.ATPreqLength = 0;
- pb.ATPreqPointer = NULL;
- pb.ATPbdsPointer = (Ptr) &dBDS;
- pb.ATPnumOfBuffs = 1;
- pb.ATPtimeOutVal = kATPTimeOutVal;
- pb.ATPretryCount = kATPRetryCount;
-
- pb.ATPaddrBlock.aNet = ABusVars->sysNetNum;
- pb.ATPaddrBlock.aNode = GetBridgeAddress();
- pb.ATPaddrBlock.aSocket = kZIPSocket;
-
- if (!pb.ATPaddrBlock.aNode) return; // no bridge -- no zones
-
- do {
- unsigned char *ptr = datapacket;
- pb.ATPuserData = kGZLCall + zIndex;
- PSendRequest(&pb, false);
- zCount += dBDS.userBytes & kZoneCount;
- while(zIndex++ <= zCount)
- {
- int count = 1 + *ptr;
- unsigned char *dest = zone_array[num_zones].c;
- while (count-- > 0) *dest++ = *ptr++;
- addtoheap(num_zones, &zone_array[num_zones]);
- num_zones++;
- }
- } until(dBDS.userBytes & kNoMoreZones);
-
- pb.ATPuserData = kGMZCall;
- datapacket[0] = 0;
- if (PSendRequest(&pb, false) == noErr && datapacket[0] &&
- datapacket[0]<32)
- for (i=0; i<=datapacket[0]; i++) myzone[i] = datapacket[i];
- }
-
- local void BuildZoneListPhase2(unsigned char *myzone)
- {
- short XPPRefNum;
- xCallParam xpb;
- unsigned char datapacket[atpMaxData];
- short zIndex=1, zCount=0;
-
- if (OpenDriver("\p.XPP", &XPPRefNum)) return;
-
- xpb.zipInfoField[0] = 0;
- xpb.zipLastFlag = FALSE;
- xpb.ioRefNum = XPPRefNum;
- xpb.csCode = xCall;
- xpb.xppSubCode = zipGetZoneList;
- xpb.xppTimeOut = kATPTimeOutVal;
- xpb.xppRetry = kATPRetryCount;
- xpb.zipBuffPtr = (Ptr)datapacket;
-
- while (!xpb.zipLastFlag && !PBControl((ParmBlkPtr)&xpb, FALSE))
- {
- unsigned char *ptr = datapacket;
- zCount += xpb.zipNumZones;
- while(zIndex++ <= zCount)
- {
- int count = 1 + *ptr;
- unsigned char *dest = zone_array[num_zones].c;
- while (count-- > 0) *dest++ = *ptr++;
- addtoheap(num_zones, &zone_array[num_zones]);
- num_zones++;
- }
- }
-
- xpb.zipInfoField[0] = 0;
- xpb.xppSubCode = zipGetMyZone;
- xpb.zipBuffPtr = (Ptr)myzone;
- PBControl((ParmBlkPtr)&xpb, FALSE);
- // Mustn't close XPP driver (see IM V 532)
- }
-
- local short addrow(ListHandle list, unsigned char *newdata)
- {
- Point pt = { 0, 0 };
- pt.v = (*list)->dataBounds.bottom;
- LAddRow(1, pt.v, list);
- LSetCell(newdata+1, newdata[0], pt, list);
- return(pt.v);
- }
-
- export int getzonelist(ListHandle zonelist)
- {
- unsigned char myzone[33];
- Point pt = { 0, 0 };
- SysEnvRec sysenvirons;
- SysEnvirons(1, &sysenvirons);
- zone_array = (ZONE_NAME *) NewPtr(MAX_ZONES * sizeof(ZONE_NAME ));
- zone_heap = (ZONE_NAME **) NewPtr(MAX_ZONES * sizeof(ZONE_NAME *));
- myzone[0] = num_zones = 0;
- if (sysenvirons.atDrvrVersNum < 53) BuildZoneListPhase1(myzone);
- else BuildZoneListPhase2(myzone);
-
- while (num_zones-->0) addrow(zonelist, removefromheap(num_zones)->c);
- DisposPtr((Ptr)zone_array);
- DisposPtr((Ptr)zone_heap);
-
- LSearch(myzone+1, *myzone, NULL, &pt, zonelist);
- LSetSelect(TRUE, pt, zonelist);
- LAutoScroll(zonelist);
- return(pt.v);
- }
-
-
- Stuart Cheshire <cheshire@cs.stanford.edu>
- * Liliore Green Rains Houses Resident Computer Coordinator
- * Stanford Distributed Systems Group Research Assistant
- * Macintosh Programmer
-
- +++++++++++++++++++++++++++
-
- From: Stuart Cheshire <cheshire@cs.stanford.edu>
- Organization: Stanford University
- Date: Wed, 2 Sep 92 18:11:08 GMT
-
- In article <1992Sep1.033635.28604@sunb10.cs.uiuc.edu> Alex Bratton,
- bratton@sparc3.cs.uiuc.edu writes:
- >If you have some sample code (ATP) that opens, registers, and dumps some
- >data, I'd really appreciate seeing it. This has been bugging me for a
- while
- >and I think I need to look at some working code to see what I'm missing.
-
- Here is some more sample code, which opens and registers an ATP socket.
- It is from the Macintosh User Authenticator mentioned in a previous post
- be me.
-
- The code is written for Think C 5.
-
- #include <Traps.h>
- #include <GestaltEqu.h>
- #include <Folders.h>
- #include <AppleTalk.h>
-
- #define local static
- #define export
- #define import extern
- typedef unsigned char BYTE;
- typedef unsigned short WORD;
- typedef unsigned long DWORD;
- #define until(A) while (!(A))
-
- typedef struct
- {
- BYTE sysLAPAddr;
- BYTE destnode;
- BYTE srcnode;
- BYTE ALAPproto;
- WORD length;
- union
- {
- struct
- {
- BYTE destsocket;
- BYTE srcsocket;
- BYTE DPPproto;
- BYTE userdata[15];
- } shortheader;
- struct
- {
- WORD checksum;
- WORD destnet;
- WORD srcnet;
- BYTE destnode;
- BYTE srcnode;
- BYTE destsocket;
- BYTE srcsocket;
- BYTE DPPproto;
- BYTE userdata[7];
- } longheader;
- } u;
- BYTE unused;
- BYTE sysABridge;
- WORD sysNetNum;
- WORD vSCCEnable;
- } MPPglobals;
-
- extern MPPglobals *ABusVars : 0x2D8;
-
- typedef struct
- {
- ATPParamBlock p;
- long *myglobals;
- } myATPParamBlock;
-
- local NamesTableEntry myNTE; /* DONT TOUCH THIS -- IT'S USED CONTINUOUSLY
- BY NBP */
-
- // name must be 8 characters long
- local void construct_name(AddrBlock addr, unsigned char *name)
- {
- static unsigned char hextable[] = "0123456789ABCDEF";
- name[0] = 7;
- name[1] = hextable[(addr.aNet >> 12) & 0xF];
- name[2] = hextable[(addr.aNet >> 8) & 0xF];
- name[3] = hextable[(addr.aNet >> 4) & 0xF];
- name[4] = hextable[(addr.aNet >> 0) & 0xF];
- name[5] = '.';
- name[6] = hextable[(addr.aNode >> 4) & 0xF];
- name[7] = hextable[(addr.aNode >> 0) & 0xF];
- }
-
- local void awaitrequest(void);
- local void acceptrequest(void)
- {
- static char dummy;
- static BDSElement bds;
-
- myATPParamBlock *atp_pb;
- long *saveGptr;
- asm { move.l GLOBREG, saveGptr
- move.l a0, atp_pb
- move.l myATPParamBlock.myglobals(a0), GLOBREG
- }
-
- // if (atp_pb->p.ATPioResult) What to do if error?
-
- // do whatever you want here to prepare your response...
-
- bds.buffSize = sizeof(dummy);
- bds.buffPtr = (Ptr)&dummy;
- bds.dataSize = 0;
- bds.userBytes = 0;
-
- atp_pb->p.ATPioCompletion = awaitrequest;
- atp_pb->p.ATPatpFlags = atpEOMvalue;
- atp_pb->p.ATPbdsPointer = (Ptr)&bds;
- atp_pb->p.ATPnumOfBuffs = 1;
- atp_pb->p.ATPbdsSize = 1;
-
- PSendResponse(&atp_pb->p, TRUE);
-
- asm { move.l saveGptr, GLOBREG }
- }
-
- local void awaitrequest(void)
- {
- static MACAUTH_REQUEST req;
- myATPParamBlock *atp_pb;
- long *saveGptr;
- asm { move.l GLOBREG, saveGptr
- move.l a0, atp_pb
- move.l myATPParamBlock.myglobals(a0), GLOBREG
- }
- atp_pb->p.ATPioCompletion = acceptrequest;
- atp_pb->p.ATPatpSocket = myNTE.nt.nteAddress.aSocket;
- atp_pb->p.ATPreqLength = sizeof(req);
- atp_pb->p.ATPreqPointer = (Ptr)&req;
- PGetRequest(&atp_pb->p, TRUE);
- asm { move.l saveGptr, GLOBREG }
- }
-
- local OSErr AppleTalkInit(void) // returns non-zero if init failed
- {
- OSErr retcode;
- short MPPRefNum;
- MPPParamBlock p;
- ATPParamBlock atp;
- static myATPParamBlock req_pb;
- static AddrBlock zeroaddress;
- static unsigned char regname[8];
-
- if (retcode = OpenDriver("\p.MPP", &MPPRefNum))
- { DebugStr("\pCouldn't open AppleTalk driver"); return(retcode); }
-
- p.SETSELF.newSelfFlag = TRUE;
- PSetSelfSend(&p, FALSE); // no need to abort if this fails
-
- atp.ATPatpSocket = 0;
- atp.ATPaddrBlock = zeroaddress;
- if (retcode = POpenATPSkt(&atp, FALSE))
- { DebugStr("\pCouldn't open ATP socket"); return(retcode); }
-
- myNTE.nt.nteAddress.aNet = ABusVars->sysNetNum;
- myNTE.nt.nteAddress.aNode = ABusVars->sysLAPAddr;
- myNTE.nt.nteAddress.aSocket = atp.ATPatpSocket;
-
- construct_name(myNTE.nt.nteAddress, regname);
-
- NBPSetNTE((Ptr)&myNTE,
- (Ptr)regname, (Ptr)"\pMacintosh Authenticator", (Ptr)"\p*",
- myNTE.nt.nteAddress.aSocket);
-
- p.NBPinterval = 2;
- p.NBPcount = 2;
- p.NBPntQElPtr = (Ptr)&myNTE;
- p.NBPverifyFlag = TRUE;
- if (retcode = PRegisterName(&p, FALSE))
- { DebugStr("\pCouldn't Register name"); return(retcode); }
-
- asm { move.l GLOBREG, req_pb.myglobals
- lea req_pb, a0
- bsr awaitrequest
- }
- }
-
-
- Stuart Cheshire <cheshire@cs.stanford.edu>
- * Liliore Green Rains Houses Resident Computer Coordinator
- * Stanford Distributed Systems Group Research Assistant
- * Macintosh Programmer
-
- ---------------------------
-
- From: sc5h+@andrew.cmu.edu (Shawn James Cokus)
- Subject: MacinTalk MPW C Interfaces
- Date: 1 Sep 92 06:33:27 GMT
- Organization: Sophomore, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
-
-
- After searching far and wide on Developer CD's (well, just the one I
- have access to, Vol. X) and Archie FTP servers, I have been at a total
- loss to find a header file for MacinTalk for MPW C and the (I believe)
- accompanying glue/library code that goes along with it. If anyone could
- tell me where to get such a beast, or even point me to some C interfaces
- that I could convert to MPW C form, it would be most appreciated.
-
- Thanks,
- - --Shawn.
- - --sc5h+@andrew.cmu.edu.
-
-
- - -- Shawn Cokus
- - -- sc5h+@andrew.cmu.edu
- - -- Carnegie-Mellon University, Pittsburgh, PA
- - -- (Witty phrase temporarily out of order.)
-
- +++++++++++++++++++++++++++
-
- From: ksand@apple.com (Kent Sandvik)
- Date: 2 Sep 92 00:35:08 GMT
- Organization: Apple
-
- In article <EecrwrC00YV7Q1Vq9v@andrew.cmu.edu>, sc5h+@andrew.cmu.edu (Shawn
- James Cokus) wrote:
- >
- >
- > After searching far and wide on Developer CD's (well, just the one I
- > have access to, Vol. X) and Archie FTP servers, I have been at a total
- > loss to find a header file for MacinTalk for MPW C and the (I believe)
- > accompanying glue/library code that goes along with it. If anyone could
- > tell me where to get such a beast, or even point me to some C interfaces
- > that I could convert to MPW C form, it would be most appreciated.
-
- The headers were shipped with the ADPA product. Macintalk does not
- run well under System 7 (especially with VM on), however there are
- hackers who have gone around the problems (like the Moose developers).
-
- The official DTS message is "stay tuned for something better".
-
- Kent Sandvik/DTS
-
- ---------------------------
-
- From: Jerome Chan <yjc@po.cwru.edu>
- Subject: screenBits, off-screen drawing and memory allocation
- Organization: Alethea, The Twilight World!
- Date: Wed, 15 Jul 92 16:51:21 GMT
-
- In the case of multiple monitors, how do I get their various dimensions
- and locations? Does screenBits.bounds contain a RECT that includes all
- monitors available? I want to draw into an off-screen area but I don't
- want to draw onto another monitor for multi-monitor configurations. I
- don't have the hardware to test this. :)
-
- When a system trap causes memory to be compacted, only the current
- application's heap zone is affected right?
-
-
- - --NewBie Mac Programmer at Large--
- - --Day 3 and Still Going
-
- - ---
- Fading
-
- "No Lah! Sure or not one? Dunno leh! Nebber Mind! Like that one!
- Terriblur Lah!"
-
- +++++++++++++++++++++++++++
-
- From: Bruce.Hoult@bbs.actrix.gen.nz
- Organization: Actrix Information Exchange
- Date: Thu, 16 Jul 1992 04:27:11 GMT
-
- In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
- > In the case of multiple monitors, how do I get their various dimensions
- > and locations? Does screenBits.bounds contain a RECT that includes all
- > monitors available?
-
- Yes. The GrayRgn is even better, since it is the real shape.
-
-
- >I want to draw into an off-screen area but I don't
- > want to draw onto another monitor for multi-monitor configurations. I
- > don't have the hardware to test this. :)
-
- Offscreen bitmaps exist in a completely diferent coordinate system
- to the real screens. You don't have to worry about them colliding.
-
-
- > When a system trap causes memory to be compacted, only the current
- > application's heap zone is affected right?
-
-
- Yes.
-
- - --
- Bruce.Hoult@bbs.actrix.gen.nz Twisted pair: +64 4 477 2116
- BIX: brucehoult Last Resort: PO Box 4145 Wellington, NZ
- "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
- hard disk that fits in your pocket!" "Great! Is it PC compatable?"
-
- +++++++++++++++++++++++++++
-
- From: lari@bach.cs.unc.edu (Humayun Lari)
- Date: 17 Jul 92 02:55:23 GMT
- Organization: University of North Carolina, Chapel Hill
-
- In article <1992Jul16.042711.23168@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
- >In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
- >> In the case of multiple monitors, how do I get their various dimensions
- >> and locations? Does screenBits.bounds contain a RECT that includes all
- >> monitors available?
- >
- >Yes. The GrayRgn is even better, since it is the real shape.
-
- If I remember correctly, screenBits.bounds is the rectangle of the main
- screen -- it doesn't enclose all monitors. Otherwise, programs that create
- or center windows based on screenBits.bounds would do rather strange things.
- :-)
-
- Humayun Lari
- (lari@cs.unc.edu)
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 18 Jul 92 02:04:00 GMT
- Organization: Core Technical Support
-
- In article <1992Jul16.042711.23168@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
- >In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
- >> In the case of multiple monitors, how do I get their various dimensions
- >> and locations? Does screenBits.bounds contain a RECT that includes all
- >> monitors available?
- >Yes. The GrayRgn is even better, since it is the real shape.
-
- As Humayun Lari pointed out, screenBits.bounds is the rect of the
- main device. The rgnBBox of the GrayRgn bounds all screens (minus the
- menu bar; see the graphic devices chapter of Inside Mac vols. V and VI
- for details on the multiple monitor environment.) Sample code for
- walking the GDevice list (to get the rect or bit depth of each screen,
- for example) is in the Q&A Stack (available on ftp.apple.com in the
- /dts/mac/docs/stacks/ directory.)
-
- >>I want to draw into an off-screen area but I don't
- >> want to draw onto another monitor for multi-monitor configurations. I
- >> don't have the hardware to test this. :)
-
- Under System 7, GWorlds are definitely the way to go. See IM VI, ch 21.
-
- >> When a system trap causes memory to be compacted, only the current
- >> application's heap zone is affected right?
- >Yes.
-
- Remember that toolbox calls may use Temp Memory these days, so potentially
- the process manager heap and the system heap could get shuffled by any
- call which "moves memory." Program defensively.
-
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
-
- +++++++++++++++++++++++++++
-
- From: Jerome Chan <yjc@po.cwru.edu>
- Organization: Alethea, The Twilight World!
- Date: Sat, 18 Jul 92 05:42:58 GMT
-
- In article <70192@apple.Apple.COM> Grobbins, grobbins@Apple.COM writes:
- >As Humayun Lari pointed out, screenBits.bounds is the rect of the
- >main device. The rgnBBox of the GrayRgn bounds all screens (minus the
-
- So I should get use the bounding rectangle of CURRENT graphics device
- if I want to perform screen calculations? And the bounding box of GrayRgn
- for a DragWindow call? screenBits can't be used if I want to drag over
- several monitors? (* I don't have the HardWare to test :( *)
-
- - ---
- Fading
-
- "No Lah! Sure or not one? Dunno leh! Nebber Mind! Like that one!
- Terriblur Lah!"
-
- +++++++++++++++++++++++++++
-
- From: lari@bach.cs.unc.edu (Humayun Lari)
- Date: 18 Jul 92 16:52:29 GMT
- Organization: University of North Carolina, Chapel Hill
-
- In article <1992Jul18.054258.12242@usenet.ins.cwru.edu> yjc@po.cwru.edu (Jerome Chan) writes:
- > So I should get use the bounding rectangle of CURRENT graphics device
- >if I want to perform screen calculations?
-
- If you want the main screen, use screenBits.bounds; if you want a particular
- screen, you should walk the GDevice list and find the screen's rectangle.
-
- >And the bounding box of GrayRgn
- >for a DragWindow call? screenBits can't be used if I want to drag over
- >several monitors? (* I don't have the HardWare to test :( *)
-
- If you specify screenBits.bounds as the limit for DragWindow, the Window
- Manager is smart enough to use the GrayRgn bounds instead.
-
-
- Humayun Lari
- (lari@cs.unc.edu)
-
- +++++++++++++++++++++++++++
-
- From: keith@taligent.com (Keith Rollin)
- Date: 18 Jul 92 20:30:25 GMT
- Organization: Taligent
-
- In article <1992Jul18.054258.12242@usenet.ins.cwru.edu>, yjc@po.cwru.edu (Jerome
- Chan) writes:
- >
- > In article <70192@apple.Apple.COM> Grobbins, grobbins@Apple.COM writes:
- > >As Humayun Lari pointed out, screenBits.bounds is the rect of the
- > >main device. The rgnBBox of the GrayRgn bounds all screens (minus the
- >
- > So I should get use the bounding rectangle of CURRENT graphics device
- > if I want to perform screen calculations? And the bounding box of GrayRgn
- > for a DragWindow call? screenBits can't be used if I want to drag over
- > several monitors? (* I don't have the HardWare to test :( *)
-
- While passing a copy of the bounding box of grayRgn to DragWindow is the
- "proper" thing to do, passing screenBits.bounds is also OK. See the description
- of DragGrayRgn (which DragWindow calls (see IM I-289)) in Inside Mac V.
-
- - --
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
-
- ---------------------------
-
- From: sichase@csa1.lbl.gov (SCOTT I CHASE)
- Subject: ZREF error
- Date: 19 Jul 92 20:39:37 GMT
- Organization: Lawrence Berkeley Laboratory - Berkeley, CA, USA
-
- I am a relative newcomer to THINK C. I have on several occassions gotten
- an error message (the verbatim text of which I have forgotten) which
- announces a ZREF error and tells me to "Remove Objects." But having done
- that as requested, the problem doesn't go away. I can only rebuild my
- application by starting over with a new project into which I load the
- identical set of libraries and files. It is as if the project file itself
- was corrupted.
-
- How am I generating the state, and how do I fix it without starting over
- with a new project? Thanks in advance.
-
- - -Scott
-
- - --------------------
- Scott I. Chase "The question seems to be of such a character
- SICHASE@CSA2.LBL.GOV that if I should come to life after my death
- and some mathematician were to tell me that it
- had been definitely settled, I think I would
- immediately drop dead again." - Vandiver
-
- +++++++++++++++++++++++++++
-
- From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
- Date: 20 Jul 92 04:00:46 GMT
- Organization: Symantec Corp.
-
- >>>>> On 19 Jul 92 20:39:37 GMT, sichase@csa1.lbl.gov (SCOTT I CHASE) said:
-
- > I am a relative newcomer to THINK C. I have on several occassions
- > gotten an error message (the verbatim text of which I have
- > forgotten) which announces a ZREF error and tells me to "Remove
- > Objects." But having done that as requested, the problem doesn't
- > go away. I can only rebuild my application by starting over with a
- > new project into which I load the identical set of libraries and
- > files. It is as if the project file itself was corrupted.
-
- > How am I generating the state, and how do I fix it without starting
- > over with a new project? Thanks in advance.
-
- The infamous ZREF error is caused by an assertion error in some
- project manipulation code which is raised when the symbol table
- appears to be corrupt. In general, this error is caused by project
- corruption of some sort, and in most cases the corruption occurs
- during the program's execution. Sometimes this corruption is slight,
- so removing objects and recompiling will fix whatever's gone wrong.
- Sometimes the project must be trashed and rebuilt from scratch.
-
- If you're seeing this error often, even after rebuilding your project
- from scratch, and if you have a large project (usually the two go hand
- in hand), you should make sure that you have a copy of your project
- which is never run, just compiled. I would have a backup that you
- update every day (week, whatever) which you can always fall back on if
- things get messed up, until you can find the bug that's causing the
- problem.
-
- -phil
- - --
- Phil Shapiro Software Engineer
- Language Products Group Symantec Corporation
- Internet: phils@cs.brandeis.edu
-
- +++++++++++++++++++++++++++
-
- From: mspace@netcom.com (Brian Hall)
- Date: 20 Jul 92 05:54:28 GMT
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
-
- phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
-
- >>>>>> On 19 Jul 92 20:39:37 GMT, sichase@csa1.lbl.gov (SCOTT I CHASE) said:
-
- > > I am a relative newcomer to THINK C. I have on several occassions
- > > gotten an error message (the verbatim text of which I have
- > > forgotten) which announces a ZREF error and tells me to "Remove
- > > Objects." But having done that as requested, the problem doesn't
- > > go away. I can only rebuild my application by starting over with a
- > > new project into which I load the identical set of libraries and
- > > files. It is as if the project file itself was corrupted.
-
- > > How am I generating the state, and how do I fix it without starting
- > > over with a new project? Thanks in advance.
-
- >The infamous ZREF error is caused by an assertion error in some
- >project manipulation code which is raised when the symbol table
- >appears to be corrupt. In general, this error is caused by project
- >corruption of some sort, and in most cases the corruption occurs
- >during the program's execution. Sometimes this corruption is slight,
- >so removing objects and recompiling will fix whatever's gone wrong.
- >Sometimes the project must be trashed and rebuilt from scratch.
-
- I used to have this problem often with a +-5M project file (the app compiled
- to over 1 M). I 'fixed' the problem by raising the memory givien to
- the Think C app significantly. I think adding at least 2M was in order,
- and I likely had the partition set to 4M. Once I did that, I *never*
- got the ZREF error again. I'm sure that does not 'fix' the real problem,
- but perhaps Think C is more likely to corrupt the project information
- when in a low memory situation.
-
- - --
-
- \ | / | Brian Hall mspace@netcom.com
- - : - | Mark/Space Softworks Applelink: markspace
- /|\ | America Online: MarkSpace
- |-+-| |
- /-\|/-\ | People don't kill people, toasters kill people.
-
- ---------------------------
-
- From: millsm@nextnet.ccs.csus.edu (Matthew Mills)
- Subject: Getting my hands on the real CLUT
- Organization: California State University Sacramento
- Date: Sat, 18 Jul 1992 19:36:49 GMT
-
- Hello all,
- I need some advice and information on controlling the screens Color
- Look-up table. I am writing a game and using machine language for
- most (if not all) the drawing, but I am having a tough time with
- setting up the indexed colors.
- The situation is this, I am moving some bullets around the screen
- and picking up the bytes that were underneath to implement some form
- of collision detection. I would like to set up ranges of colors
- used by the good guys, and another range for the enemies. I have
- looked into the palette manager but it is not truly associated with
- the indexes of the video memory.
- What is the proper way to look at and change the CLUT for a
- particular display? Being a game (which takes over the whole
- screen) following the proper color manager practices is not
- important. I know this sounds like I will get a visit from the
- Interface police but I'll do my time ;-)
-
- Matthew
-
- - --
- | Matthew Mills | To do is to be - Socrates
- | Technical Lab Assistant (CSUS) | To be is to do - Plato
- | mail-> millsm@csus.edu | Do Be Do Be Do - Sinatra
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Organization: Kalamazoo College
- Date: Mon, 20 Jul 1992 00:03:18 GMT
-
- millsm@nextnet.ccs.csus.edu (Matthew Mills) writes:
- >
- > I need some advice and information on controlling the screens Color
- > Look-up table. I am writing a game and using machine language...
- > ...I would like to set up ranges of colors
- > used by the good guys, and another range for the enemies. I have
- > looked into the palette manager but it is not truly associated with
- > the indexes of the video memory.
-
- It can be. If you set color n in the palette to be
- pmAnimated+pmExplicit, it will correspond to color n in the color table,
- for 0 < n < theIndexOfTheLastColorInTheCLUT.
-
- > What is the proper way to look at and change the CLUT for a
- > particular display? Being a game (which takes over the whole
- > screen) following the proper color manager practices is not
- > important.
-
- If you can give up those first and last colors, use the Palette Manager.
- It's actually easier than the Color Manager (it cleans up for you) and
- you won't have to rip your hair out if you ever decide to put your game
- in a window smaller than a full screen.
-
- To do this, set up a palette with pmAnimated+pmExplicit colors in the
- range from 1 to theSecondToLastColorInTheCLUT. Attach the palette to
- your window with SetPalette(). To change their colors, call
- AnimatedPalette(). That's all there is to it, if you're writing
- directly to the screen (which it sounds like you are).
-
- > I know this sounds like I will get a visit from the
- > Interface police but I'll do my time ;-)
-
- Oh, you probably won't spend any time behind bars--the jails are full,
- and judges are starting to let people go with just warnings.
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- I just got Think C and I like it so much that I had to tell the world.
- I used to be an MPW bigot, but no more. - John Norstad, 10 July 1992
-
- ---------------------------
-
- From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
- Subject: FSpExchangeFiles Problem
- Date: 17 Jul 92 01:11:03 GMT
- Organization: Bucknell University, Lewisburg, Pa.
-
- I'm having a problem with FSpExchangeFiles.
-
- The problem occurs when I try to exchange a temporary file with a
- permanent file (the file that I'm trying to save) that is on a
- different volume than my system folder. In this case, my call to
- FSpExchangeFiles returns a -50, "Error in user parameter list". This
- puzzles me for two reasons.
-
- - - The code works when the permanent file is on the same volume as the
- system folder.
-
- - - I am able to write to the temporary file and read from the permanent
- file without any problems. Doesn't this indicate that the FSSpec
- records for my files are correct?
-
- Please help.
-
- Rick Zaccone
- - --
- zaccone@bucknell.edu
-
- +++++++++++++++++++++++++++
-
- From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
- Date: 17 Jul 92 12:23:03 GMT
- Organization: Bucknell University, Lewisburg, Pa.
-
- A couple of people have been kind enough to point out that
- FSpExchangeFiles can't work across volumes because it just exchanges
- directory information. I've reread IM Vol. VI and it does indeed make
- (quick) reference to the fact that both files should be on the same
- volume.
-
- This raises some disturbing questions for me.
-
- - - How would I do a safe save when the file I'm trying to save is not
- on the start-up volume? Specifically, where would I put the temp
- file? How have other people handled this? Why doesn't IM address
- this issue?
-
- - - Suppose there's no easy way to do a safe save in this situation.
- I'm disturbed by the fact that there would be more security in a save
- to the start-up volume than to other volumes. I would like them all
- to be equally safe.
-
- Rick Zaccone
- - --
- zaccone@bucknell.edu
-
- +++++++++++++++++++++++++++
-
- From: laf@mitre.org (Lee Fyock)
- Organization: The MITRE Corporation
- Date: Fri, 17 Jul 1992 12:49:02 GMT
-
- In article <ZACCONE.92Jul16211103@rigel.cs.bucknell.edu>,
- zaccone@rigel.cs.bucknell.edu (Rick Zaccone) wrote:
- >
- > I'm having a problem with FSpExchangeFiles.
- >
- > The problem occurs when I try to exchange a temporary file with a
- > permanent file (the file that I'm trying to save) that is on a
- > different volume than my system folder. In this case, my call to
- > FSpExchangeFiles returns a -50, "Error in user parameter list". This
- > puzzles me for two reasons.
- >
- > - The code works when the permanent file is on the same volume as the
- > system folder.
- >
- > - I am able to write to the temporary file and read from the permanent
- > file without any problems. Doesn't this indicate that the FSSpec
- > records for my files are correct?
-
- I've seen this error before, usually when using a working directory
- refnum in a place where a straight volume refnum is expected. This
- seems to crop up with major problems only when filesharing is on...
-
- Lee
-
- - ------------------------------------------------------------------------
- Lee Fyock The MITRE Corporation
- laf@mitre.org Bedford, Massachusetts
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Organization: Kalamazoo College
- Date: Fri, 17 Jul 1992 13:51:21 GMT
-
- zaccone@bucknell.edu writes:
- >
- >- How would I do a safe save when the file I'm trying to save is not
- >on the start-up volume? Specifically, where would I put the temp
- >file? How have other people handled this? Why doesn't IM address
- >this issue?
-
- I don't see any reason why you would have to put the temp file in the
- Temporary Items Folder (which it sounds like you're doing). That's just
- for files that remain open long enough for users to mess with them if
- they're anywhere else. :-)
-
- If you create, write, swap, and delete the temporary file without
- calling WaitNextEvent, the user will never see it, and you can put it
- anywhere you want.
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- I'm having a lot of trouble seeing how a request that you "shut up" can be
- interpreted as "looking to other people for validation." - Tim Pierce
-
- +++++++++++++++++++++++++++
-
- From: keith@taligent.com (Keith Rollin)
- Date: 17 Jul 92 19:10:48 GMT
- Organization: Taligent
-
- In article <ZACCONE.92Jul17082303@rigel.cs.bucknell.edu>,
- zaccone@rigel.cs.bucknell.edu (Rick Zaccone) writes:
- >
- > A couple of people have been kind enough to point out that
- > FSpExchangeFiles can't work across volumes because it just exchanges
- > directory information. I've reread IM Vol. VI and it does indeed make
- > (quick) reference to the fact that both files should be on the same
- > volume.
- >
- > This raises some disturbing questions for me.
- >
- > - How would I do a safe save when the file I'm trying to save is not
- > on the start-up volume? Specifically, where would I put the temp
- > file? How have other people handled this? Why doesn't IM address
- > this issue?
- >
- > - Suppose there's no easy way to do a safe save in this situation.
- > I'm disturbed by the fact that there would be more security in a save
- > to the start-up volume than to other volumes. I would like them all
- > to be equally safe.
-
- I'm not sure what the problem here is. Performing a "safe save" refers to the
- process of replacing the contents of a file with new information in such a way
- that the old information is preserved in case an error arises. If the old file
- is on volume A, and you are writing the new file to volume B, then you are not
- replacing the old file, and "safe save" techniques are not needed. Just write
- the new file to volume B. If it succeeds, delete the file from volume A (if
- that's what you want). I don't see a need for temp files or for calling
- FSpExchangeFiles.
-
- - --
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
-
- +++++++++++++++++++++++++++
-
- From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
- Date: 18 Jul 92 01:17:06 GMT
- Organization: Bucknell University, Lewisburg, Pa.
-
- I now realize my problem. I was always creating my temporary file on
- the start-up volume. I'm not sure where I got the idea that that was
- the right place to do it, but clearly it's not. If I want to make a
- temporary file so that I can use FSpExchangeFiles, then I need to do
- so on the same volume as the permanent file.
-
- Rick
- - --
- zaccone@bucknell.edu
-
-
- +++++++++++++++++++++++++++
-
- From: lari@bach.cs.unc.edu (Humayun Lari)
- Date: 18 Jul 92 17:25:32 GMT
- Organization: University of North Carolina, Chapel Hill
-
- In article <1992Jul17.135121.26241@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
- >I don't see any reason why you would have to put the temp file in the
- >Temporary Items Folder (which it sounds like you're doing). That's just
- >for files that remain open long enough for users to mess with them if
- >they're anywhere else. :-)
- >
- >If you create, write, swap, and delete the temporary file without
- >calling WaitNextEvent, the user will never see it, and you can put it
- >anywhere you want.
-
- But what if your program crashes while it's saving, or the power goes out?
- If you use the temporary items folder, at least the portion of the document
- you finished saving will show up in the "Rescued Items" folder at startup. If
- you put the file somewhere else, the user might not notice it, and need to
- redo work unnecessarily.
-
- Humayun Lari
- (lari@cs.unc.edu)
-
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Organization: Kalamazoo College
- Date: Mon, 20 Jul 1992 18:01:36 GMT
-
- lari@bach.cs.unc.edu (Humayun Lari) writes:
- >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
- >>I don't see any reason why you would have to put the temp file in the
- >>Temporary Items Folder...
- >
- >But what if your program crashes while it's saving, or the power goes out?
- >If you use the temporary items folder, at least the portion of the document
- >you finished saving will show up in the "Rescued Items" folder at startup. If
- >you put the file somewhere else, the user might not notice it, and need to
- >redo work unnecessarily.
-
- Right. I forgot that you can specify a temp folder on any volume.
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- I suppose ya don't think I was run over by a streetcar!
-
- ---------------------------
-
- From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
- Subject: Accepting AppleEvents?
- Organization: University of Illinois at Urbana
- Date: Thu, 16 Jul 1992 03:30:06 GMT
-
- I am trying to write a very simple application that accepts the four
- required AppleEvents. I have been following the example in Inside Mac
- VI, but I am writing in Think C, and I am having a little trouble
- converting.
-
- I mainly need the odoc event. I have successfully installed a handler
- to handle the odoc event, but when this function calls AEGetParamDesc,
- it returns an error of -1704. It seems that my AppleEvent is not
- properly formed.
-
- Does anyone have either of the following written in C:
-
- (1) source code for a SIMPLE application that does nothing but accepts
- the four required AppleEvents, or
- (2) source code for a handler function that handles the odoc
- AppleEvent.
-
- Thanks.
- - --
- David M. Marcovitz | internet: marcovitz@uiuc.edu
- Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu
- University of Illinois | novanet: marco / cca / nova
-
- +++++++++++++++++++++++++++
-
- From: rla20@duts.ccc.amdahl.com (Roger Allen)
- Date: 16 Jul 92 22:15:55 GMT
- Organization: Amdahl Corporation, Sunnyvale CA
-
- In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
- >
- >Does anyone have either of the following written in C:
- >
- >(1) source code for a SIMPLE application that does nothing but accepts
- > the four required AppleEvents, or
- >(2) source code for a handler function that handles the odoc
- > AppleEvent.
- >
-
- How about the basic TCL shell program that comes with THINK C?
-
- Roger
- - --
- > Roger Allen | <
- > Amdahl Computer Development | What are you looking here for? <
- > rla20@cd.amdahl.com | <
-
- +++++++++++++++++++++++++++
-
- From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
- Organization: University of Illinois at Urbana
- Date: Fri, 17 Jul 1992 00:47:30 GMT
-
- rla20@duts.ccc.amdahl.com (Roger Allen) writes:
-
- >In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
- >>
- >>Does anyone have either of the following written in C:
- >>
- >>(1) source code for a SIMPLE application that does nothing but accepts
- >> the four required AppleEvents, or
- >>(2) source code for a handler function that handles the odoc
- >> AppleEvent.
- >>
-
- >How about the basic TCL shell program that comes with THINK C?
-
- Thanks for the advice. I had been using the TCL shell to try to
- figure it out. It helped some. After some hacking, I finally got the
- program to work, but I'm still not sure why.
-
- - --
- David M. Marcovitz | internet: marcovitz@uiuc.edu
- Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu
- University of Illinois | novanet: marco / cca / nova
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 18 Jul 92 03:00:59 GMT
- Organization: The Ortiz Organization
-
- In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
- >Does anyone have either of the following written in C:
- >(1) source code for a SIMPLE application that does nothing but accepts
- > the four required AppleEvents, or
- >(2) source code for a handler function that handles the odoc
- > AppleEvent.
-
- (2) is totally application dependent, so I doubt you'll find anything
- more useful than Inside Mac VI's sample code.
-
- Here's a 1-1/2 page faceless background application for System 7
- which answers (1).
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
- - ---
-
-
- #include "AppleEvents.h"
- #include "GestaltEqu.h"
-
- #define kSleepMax 50000 // long sleep time to avoid stealing cycles
-
- Boolean gAppleEventsFlag, gQuitFlag;
- long gSleepVal;
-
- pascal OSErr DoAEOpenApplication(AppleEvent * theAppleEvent,
- AppleEvent * replyAppleEvent,
- long refCon)
- {
- #pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return noErr;
- }
-
- pascal OSErr DoAEOpenDocuments(AppleEvent * theAppleEvent,
- AppleEvent * replyAppleEvent,
- long refCon)
- {
- #pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return errAEEventNotHandled;
- }
-
- pascal OSErr DoAEPrintDocuments(AppleEvent * theAppleEvent,
- AppleEvent * replyAppleEvent,
- long refCon)
- {
- #pragma unused (theAppleEvent, replyAppleEvent, refCon)
- return errAEEventNotHandled;
- }
-
- pascal OSErr DoAEQuitApplication(AppleEvent * theAppleEvent,
- AppleEvent * replyAppleEvent,
- long refCon)
- {
- #pragma unused (theAppleEvent, replyAppleEvent, refCon)
- gQuitFlag = true;
- return noErr;
- }
-
- void InitAppleEventsStuff(void)
- // install Apple event handlers
- {
- OSErr retCode;
-
- if (gAppleEventsFlag) {
-
- retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
- (EventHandlerProcPtr) DoAEOpenApplication, 0, false);
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
- (EventHandlerProcPtr) DoAEOpenDocuments, 0, false);
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
- (EventHandlerProcPtr) DoAEPrintDocuments, 0, false);
- if (retCode == noErr)
- retCode = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
- (EventHandlerProcPtr) DoAEQuitApplication, 0, false);
- if (retCode != noErr) DebugStr("\pInstall event handler failed");
- }
- }
-
- void DoHighLevelEvent(EventRecord * theEventRecPtr)
- // high-level event dispatching
- {
- (void) AEProcessAppleEvent(theEventRecPtr);
- }
-
- main()
- {
- OSErr retCode;
- long gestResponse;
-
- EventRecord mainEventRec;
- Boolean eventFlag;
-
- // initialize globals
-
- gQuitFlag = false;
- gSleepVal = kSleepMax;
-
- // is the Apple Event Manager available?
- retCode = Gestalt(gestaltAppleEventsAttr, &gestResponse);
- if (retCode == noErr &&
- (gestResponse & (1 << gestaltAppleEventsPresent)) != 0)
- gAppleEventsFlag = true;
- else gAppleEventsFlag = false;
-
- // install Apple event handlers
- InitAppleEventsStuff();
-
- while (!gQuitFlag) {
- eventFlag = WaitNextEvent(everyEvent, &mainEventRec, gSleepVal, nil);
-
- if (mainEventRec.what == kHighLevelEvent)
- DoHighLevelEvent(&mainEventRec);
- }
- }
-
-
- +++++++++++++++++++++++++++
-
- From: potts@itl.itd.umich.edu (Paul Potts)
- Organization: Instructional Technology Laboratory, University of Michigan
- Date: Mon, 20 Jul 92 20:02:55 GMT
-
- In article <BrICv7.KxE@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
- > ...After some hacking, I finally got the
- >program to work, but I'm still not sure why.
-
- Welcome to Macintosh programming! : ) Can I quote you? This sums it up
- pretty well.
-
-
- - --
- ..though I respect that a lot, I'd be fired if that were my job, after
- killing Jason off and countless screaming argonauts... (They Might Be Giants)
- Paul R. Potts, Software Designer --- potts@itl.itd.umich.edu <--- me!
-
- +++++++++++++++++++++++++++
-
- From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
- Organization: University of Illinois at Urbana
- Date: Mon, 20 Jul 1992 21:24:40 GMT
-
- I believe that the important part of getting my AppleEvents handlers
- to work was to declare the functions to be of type pascal OSErr.
- The "pascal" part is very important.
-
- pascal OSErr myEventHandler(AppleEvent *event, AppleEvent *reply, long ref);
-
- I believe this is the correct header.
-
- - --
- David M. Marcovitz | internet: marcovitz@uiuc.edu
- Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu
- University of Illinois | novanet: marco / cca / nova
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-